package it.disim.tlp.webreputation.plugin;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;
import com.restfb.types.User;
import it.disim.tlp.webreputation.aggregatorplugin.AggregatorPlugin;
import it.disim.tlp.webreputation.aggregatorplugin.AggregatorPost;
import it.disim.tlp.webreputation.exceptions.QuotaExceededException;

public class AdvancedPlugin2 implements AggregatorPlugin {

	FacebookClient facebookClient = new DefaultFacebookClient("CAACEdEose0cBADs3NXCvFZBjIVzNcklMzCQVkk1ayh4l9WdYWGgBpZBLeuR2QqzwcUQj5c1YR7fGSvnqA9KpIvTQlMJ1qCMf79VKENKjpynC7ZAu2YWS69ihYH3RcYZCiMJZCVCFt3tQLoTiFvZCfhQFbtsdgCCGsHD0xZCz3qkIAZDZD");
	User user = facebookClient.fetchObject("me", User.class);

	@Override
	public List<AggregatorPost> getPosts(String resource, Date to) throws QuotaExceededException {
		List<AggregatorPost> splist = new ArrayList<AggregatorPost>();
		AggregatorPost sp = new AggregatorPost();
		sp.setAuthor(user.getName());
		sp.setDate(new Date());
		sp.setSource("fb");
		sp.setText(user.getBio());
		splist.add(sp);
		return splist;
	}

	@Override
	public List<AggregatorPost> getPosts(String resource, Date from, Date to) throws QuotaExceededException {
		List<AggregatorPost> splist = new ArrayList<AggregatorPost>();
		AggregatorPost sp = new AggregatorPost();
		sp.setAuthor(user.getName());
		sp.setDate(new Date());
		sp.setSource("fb");
		sp.setText(user.getBio());
		splist.add(sp);
		return splist;
	}

}
